package com.zhigh.project.security.jwt.authentication;

import com.zhigh.project.security.jwt.authentication.exception.JWTAuthenticationException;
import com.zhigh.project.tools.Assertions;

public class DefaultJWTHeader implements JWTHeader {

    private final String alg;

    private String typ = "JWT";

    public DefaultJWTHeader(String alg) {
        this.alg = alg;
    }

    public static JWTHeader of(String algorithm) {
        return new DefaultJWTHeader(
                Assertions.assertNonBlank(algorithm, () -> new JWTAuthenticationException("Algorithm is blank."))
        );
    }

    @Override
    public String getAlg() {
        return alg;
    }

    public void setTyp(String typ) {
        this.typ = typ;
    }

    @Override
    public String getTyp() {
        return typ;
    }
}
